export default {
    namespaced: true,
    state: {
        // 控制提示框组件的显示和隐藏
        isShowToast: false,// 关闭提示
        msg: "",// 提示的内容
        type: '' // 提示的类型
    },
    mutations: {
        //修改isShowToast值
        changeIsShowToast(state, playload) {
            //将Topbar组件中的用户点击hdClick()方法传过来的值赋给state
            //success 成功
            //warning 警告
            //danger 失败
            state.isShowToast = playload.isShow
            state.msg = playload.msg
            state.type = playload.type
        }
    },

    getters: {
    },

    actions: {

        asyncChangeIsShowToast(state, playload) {
            //向mutations里changeIsShowToast的方法提交数据
            state.commit('changeIsShowToast', {
                isShow: true,// 打开提示
                msg: playload.msg,
                type: playload.type,
            })

            //2秒后隐藏提示框
            let timer = setInterval(() => {
                clearInterval(timer)
                state.commit('changeIsShowToast', {
                    isShow: false,// 关闭提示
                    msg: playload.msg,
                    type: playload.type,
                })
            }, 2000);
        }
    }



}